// import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_application_1/base_layout.dart';
import 'package:flutter_application_1/dian_zan.dart';
import 'package:flutter_application_1/form_list.dart';
import 'package:flutter_application_1/mian_list.dart';

void main() {
  runApp(const MyApp());
  //DianZanVC
  // runApp(const DianZanVC());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '首页',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MianListVC(),
      routes: <String, WidgetBuilder>{
        "zan": (BuildContext context) => DianZanVC(),
        "base": (BuildContext context) => BaseLayoutVC(),
        "form": (BuildContext context) => FormListVC(),
      },
    );
  }
}

// class MyHomePage extends StatefulWidget {
//   const MyHomePage({Key? key, required this.title}) : super(key: key);

//   final String title;

//   @override
//   State<MyHomePage> createState() => _MyHomePageState();
// }

// class _MyHomePageState extends State<MyHomePage> {
//   int _counter = 0;

//   void _incrementCounter() {
//     setState(() {
//       _counter++;
//     });
//   }

//   @override
//   Widget build(BuildContext context) {
//     return Scaffold(
//       appBar: AppBar(
//         title: Text(widget.title),
//       ),
//       body: Center(
//         child: Column(
//           mainAxisAlignment: MainAxisAlignment.center,
//           children: <Widget>[
//             const Text(
//               'You have pushed the button this many times:',
//             ),
//             Text(
//               '$_counter',
//               style: Theme.of(context).textTheme.headline4,
//             ),
//           ],
//         ),
//       ),
//       floatingActionButton: FloatingActionButton(
//         onPressed: _incrementCounter,
//         tooltip: 'Increment',
//         child: const Icon(Icons.add),
//       ), // This trailing comma makes auto-formatting nicer for build methods.
//     );
//   }
// }

class HomePageVC extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('首页'),
        ),
        body: ListView(
          children: [
            HomePageItem('apple1', 'apple1 good',
                'https://tva1.sinaimg.cn/large/006y8mN6gy1g72j6nk1d4j30u00k0n0j.jpg'),
            HomePageItem('apple2', 'apple2 good',
                'https://tva1.sinaimg.cn/large/006y8mN6gy1g72imm9u5zj30u00k0adf.jpg'),
            HomePageItem('apple3', 'apple3 good',
                'https://tva1.sinaimg.cn/large/006y8mN6gy1g72imqlouhj30u00k00v0.jpg'),
          ],
        ));
  }
}

//cell样式
class HomePageItem extends StatelessWidget {
  final String title;
  final String desc;
  final String imgUrl;

  final style1 = TextStyle(fontSize: 25, color: Colors.orange);
  final style2 = TextStyle(fontSize: 20, color: Colors.green);

  HomePageItem(this.title, this.desc, this.imgUrl);
  @override
  Widget build(BuildContext context) {
    return Container(
        padding: EdgeInsets.all(12),
        decoration:
            BoxDecoration(border: Border.all(width: 4, color: Colors.pink)),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            Row(
              children: [
                Text(title, style: style1),
              ],
            ),
            SizedBox(height: 8),
            Text(desc, style: style2),
            SizedBox(height: 8),
            Image.network(imgUrl)
          ],
        ));
  }
}
